#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

struct ele {
	int a, b, c, cnt, ret;
	friend bool operator == (ele x, ele y) {
		return x.a == y.a && x.b == y.b && x.c == y.c;
	}
} pt[N], t[N];

int n, K, m;

namespace T {
	int tr[N];
	void add(int x, int v) { for(; x <= K; x += x & -x) tr[x] += v; }
	int query(int x) { int ret = 0; for(; x; x -= x & -x) ret += tr[x]; return ret; }
	void clear() { rep(i, 1, K) tr[i] = 0; }
};

void divide(int l, int r) {
	if(l == r) return; int mid = l + r >> 1;
	divide(l, mid), divide(mid + 1, r);
	int p1 = l, p2 = mid + 1;
	while(p1 <= mid && p2 <= r) {
		if(t[p1].b <= t[p2].b) T :: add(t[p1].c, t[p1].cnt), p1++;
		else t[p2].ret += T :: query(t[p2].c), p2++;
	}
	while(p2 <= r) t[p2].ret += T :: query(t[p2].c), p2++;
	//T :: clear();
	p1--; while(p1 >= l) T :: add(t[p1].c, -t[p1].cnt), p1--;
	//merge(t + l, t + mid + 1, t + mid + 1, t + r + 1, t + l, [&]);
	inplace_merge(t + l, t + mid + 1, t + r + 1, [&](auto x, auto y) {
		return x.b ^ y.b ? x.b < y.b : x.c ^ y.c ? x.c < y.c : x.a < y.a;
	});
}

int ans[N];

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, K = in; rep(i, 1, n) pt[i].a = in, pt[i].b = in, pt[i].c = in;
	sort(pt + 1, pt + n + 1, [&](auto x, auto y) {
		return x.a ^ y.a ? x.a < y.a : x.b ^ y.b ? x.b < y.b : x.c < y.c;
	});
	rep(i, 1, n) {
		if(pt[i] == t[m]) t[m].cnt++;
		else ++m, t[m] = pt[i], t[m].cnt++;
	}
	divide(1, m);
	rep(i, 1, m) ans[t[i].ret + t[i].cnt - 1] += t[i].cnt;
	rep(i, 0, n - 1) printf("%d\n", ans[i]);
	return 0;
}
